package com.example.ttt.functions;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import java.util.List;

/*
* 进行文件扫描
* */

@Component
@Slf4j
public class Scanner_Music {

    @Autowired
    private Environment environment;
    @Autowired
    private GetDocumentList getDocumentList;
    @Autowired
    private TableFill tableFill;

    public void scannerMusic() {

        String scannerFilePath = environment.getProperty("scannerFilePath");
        log.info("文件夹地址：{}",scannerFilePath);
        //设置默认model
        //判断文件路径是否为空
        if (!scannerFilePath.isEmpty()) {
            //输出获取到的xml文件结果
            //将扫描到的文件路径set给扫描对象
            List list = getDocumentList.Get_List(scannerFilePath);
            //像表格填充数据
            tableFill.tableFillData(list);
        }else {
            log.info("更新数据失败，地址为空……");
        }
    }
}
